package wechat

import (
	"code.gitea.io/gitea/modules/web"
	context "code.gitea.io/gitea/services/context"
	wechat_service "code.gitea.io/gitea/services/wechat"
)

/*
 * 注册微信
 *    前缀 "/api/wechat"
 */
func InitWechatRoutes() *web.Router {

	wechatWebRouter := web.NewRouter()
	wechatWebRouter.Use(context.APIContexter())

	// 微信服务器回调接口
	wechatWebRouter.Group("/callback", func() {
		wechatWebRouter.Get("/message", wechat_service.CallbackVerifyMessage)
		wechatWebRouter.Post("/message", wechat_service.CallbackNotifyEvents)
	})

	// 微信公众号带参数临时二维码登录
	wechatWebRouter.Group("/login/qr", func() {
		wechatWebRouter.Get("/generate", wechat_service.GenerateWechatQrCode)
		wechatWebRouter.Get("/check-status", wechat_service.QrCheckCodeStatus)
	})

	return wechatWebRouter
}
